<?php
/***************************************************************
*  Copyright notice
*  (c) 2007, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the MyGodaddy project.
***************************************************************/

//
set_time_limit(0);

//
$_root = str_replace('\\', '/', dirname(dirname(__FILE__))) . '/';
$dir = 'images/A/PhotoRS/';

//
include($_root . 'includes/utils.php');
include($_root . 'includes/classes/core.directory.class.php');
$dirObj = new CoreDirectoryParser('', $dir, $_root);
$dirObj->parse();
$dirs = $dirObj->getDirs();
$files = $dirObj->getFiles();
$real_dir = $dirObj->getRealDir();

//
foreach($dirs as $k => $v) {
	$dirObj = new CoreDirectoryParser('', $dir . $v . '/', $_root);
	$dirObj->parse();
	$files = $dirObj->getFiles();
	$real_dir = $dirObj->getRealDir();
	
	for($i=0, $n=sizeof($files); $i<$n; $i++) {
		if( file_exists($real_dir . $files[$i]['file']) && strstr($files[$i]['file'], 'gyso europe 2005 ') ) {
			$filename = str_replace("gyso europe 2005 ", "", $files[$i]['file']);
			
			if( !file_exists($real_dir . $filename) ) {
				rename($real_dir . $files[$i]['file'], $real_dir . $filename);
			}
			echo $filename;
			echo '<br>';
		}
	}
}

//
echo 'SUCCESS';
//
?>